package com.cskaoyan.connectionpool;

import com.cskaoyan.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建日期: 2022/04/22 15:15
 *
 * @author ciggar
 */
public class MyConnectionPoolTest {

    public static void main(String[] args) throws SQLException {

        // 获取连接
        Connection connection = DruidUtils.getConnection();

        Statement statement = connection.createStatement();

        ResultSet resultSet = statement.executeQuery("select * from account where id = 2");



        while (resultSet.next()) {

            String name = resultSet.getString("name");
            int id = resultSet.getInt("id");

            System.out.println("id:" + id + ", name:" +name);
        }


        // 关闭其他的资源 , 注意：连接一定不能关闭了之后再返回到数据库连接池
        JDBCUtils.close(connection,statement,resultSet);


    }
}
